package com.ruoyi.mining.domain;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;

/**
 * 试卷对象 mn_paper
 *
 * @author mining
 * @date 2025-05-23
 */
@Data
@ToString
@ApiModel(value = "试卷对象", description = "试卷对象")
public class Paper {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private String id;

    @ApiModelProperty(value = "标题")
    @Excel(name = "标题")
    private String title;

    @ApiModelProperty(value = "type 选 ： 小升初 ,初升高,高考")
    @Excel(name = "期末，小升初")
    private String type;

    @ApiModelProperty(value = "年级")
    @Excel(name = "年级")
    private String grade;

    @ApiModelProperty(value = "科目")
    @Excel(name = "科目")
    private String  subject;

    @ApiModelProperty(value = "学校1巴蜀 2一中 3南开南渝  4八中  5西附 6一外 7育才 8其他")
    @Excel(name = "学校")
    private String school;


    @ApiModelProperty(value = "考试时间")
    @Excel(name = "考试时间")
    private String examDate;

    @ApiModelProperty(value = "试卷链接")
    @Excel(name = "试卷链接")
    private String url;

    @ApiModelProperty(value = "联系电话")
    @Excel(name = "联系电话")
    private String phone;




    @ApiModelProperty(value = "下载次数")
    @Excel(name = "下载次数")
    private Integer downloadTimes;

    @ApiModelProperty(value = "录入人")
    @Excel(name = "录入人")
    private String createUser;

    @ApiModelProperty(value = "录入日期")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "录入日期", width = 30, dateFormat = "yyyy-MM-dd")
    private String createDate;

    @ApiModelProperty(value = "试卷类型 期中，期末，小升初")
    @Excel(name = "试卷类型")
    private String category;



    public String getUrl() {
        if(StringUtils.isNotEmpty( url )){
            url=url.replaceAll( "viewImage","viewPdf");
        }
        if ("https://data.lvlianhengsheng.com/dev-api".equalsIgnoreCase(url) || StringUtils.countMatches(url, "http") > 1) {
            return null;
        }
        if (com.ruoyi.common.core.utils.StringUtils.isNotEmpty(url) && !url.contains("http")) {
            return "https://data.lvlianhengsheng.com/dev-api/file/fileAttachmentInfo/viewPdf?key=" + url;
        }
//        https://data.lvlianhengsheng.com/dev-api/file/fileAttachmentInfo/viewImage?key=FJ3c8280647d1a1b28648cf4cdbaea117a
        return url;
    }

}
